<template>
  <div class="loginBox">
    <div class="login">
      <login-component v-if="activeName === 'login'" @active="handleActive"></login-component>
      <register-component v-if="activeName === 'register'" @active="handleActive"></register-component>
      <resetpwd-component v-if="activeName === 'resetpwd'" @active="handleActive"></resetpwd-component>
    </div>
  </div>
</template>

<script>
import LoginComponent from './components/login'
import RegisterComponent from './components/register'
import ResetpwdComponent from './components/resetpwd'
import { mapGetters } from 'vuex'
export default {
  name: "login",
  computed:{
    ...mapGetters([
      'userInfo'
    ]),
  },
  components: {
    LoginComponent,
    RegisterComponent,
    ResetpwdComponent
  },
  data() {
    return {
      activeName: 'register'
    };
  },

  methods:{
    handleActive(name) {
      this.$router.replace(`/${this.$route.params.role}/auth/${name}`)
    },
    handleRoute() {
      this.activeName = this.$route.params.type || 'register'
    }
  },
  watch: {
    '$route': 'handleRoute'
  },
  created() {
    this.activeName = this.$route.params.type || 'register'
    if (!this.$route.params.role) {
      this.$confirm('请选择注册角色', '提示', {
        confirmButtonText: '我是企业',
        cancelButtonText: '我是个人',
        center: true
      }).then(() => {
        this.$router.replace('/company/auth/register')   
      }).catch(() => {
        this.$router.replace('/personal/auth/register')        
      })
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped>
.loginBox {
  width: 100vw;
  height: 100vh;
  background-color: #ffffff;
  position: relative;
  background: url(/images/login_bg.jpg) no-repeat center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  color: rgba(255, 255, 255, 0.95);
  overflow: hidden;
}
.login {
  box-sizing: border-box;
  max-width: 550px;
  height: auto;
  background-color: aquamarine;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.2);
  border: 10px solid rgba(255, 255, 255, 0.3);
  -moz-box-shadow: 0 3px 0 rgba(12, 12, 12, 0.03);
  -webkit-box-shadow: 0 3px 0 rgba(12, 12, 12, 0.03);
  box-shadow: 0 3px 0 rgba(12, 12, 12, 0.03);
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
  border-radius: 5px;
  padding: 30px 30px 50px 30px;
  text-align: center;
}
.login h1 {
  font-size: 24px;
  line-height: 24px;
  margin-bottom: 24px;
  letter-spacing: 0.2em;
}
.login .elRadioBox {
  width: 100%;
  height: 40px;
  margin-top: 14px;
}
.el-radio {
  color: #fff;
}
.login .el-input {
  width: 320px;
  height: 40px;
  margin-bottom: 14px;
}
.login .el-button {
  width: 320px;
  height: 40px;
}
</style>
